const path = require('path');
module.exports = {
  // 配置别名
  webpack: {
    // 别名
    alias: {
      '@@/': path.resolve(__dirname, './'),
      '@asset': path.resolve(__dirname, 'src/assets'),
      '@config': path.resolve(__dirname, 'src/config'),
      '@component': path.resolve(__dirname, 'src/components'),
      '@layout': path.resolve(__dirname, 'src/layouts'),
      '@hook': path.resolve(__dirname, 'src/hooks'),
      '@route': path.resolve(__dirname, 'src/routes'),
      '@view': path.resolve(__dirname, 'src/views'),
      '@model': path.resolve(__dirname, 'src/models'),
      '@service': path.resolve(__dirname, 'src/services'),
      '@util': path.resolve(__dirname, 'src/utils'),
      '@lib': path.resolve(__dirname, 'src/lib'),
    },
  },
  devServer: {
    // 浏览器自动打开关闭
    // https: true,
    open: false,
    port: 8080,
    host: 'localhost',
    proxy: {
      '/api': {
        // 代理地址（后端的地址
        target: 'http://localhost:7001',
        // 设置服务器是否会收到hook，默认false
        changeOrigin: true,
        // pathRewrite: {'^/api': ''},
      },
    },
    setupMiddlewares: (middlewares, devServer) => {
      // app它就是express的实例对象
      // 必须要把middlewares对象返回
      // require('./mock/index')(devServer.app, middlewares);
      // console.log('middlewares', middlewares);
      return middlewares;
    },
  },
};
